package chapter5.No5_1_定时器Timer的使用.demo6;

import java.util.Calendar;
import java.util.Date;
import java.util.Timer;

/**
 * TimerTask的cancel()方法是将任务从timer中清除
 */
public class Main {
    public static void main(String[] args) {
        Calendar c = Calendar.getInstance();
        c.add(Calendar.SECOND, 5);
        Date d = c.getTime();
        System.out.println("b预计时间："+d);

        MyTaskA a = new MyTaskA();
        MyTaskB b = new MyTaskB();

        Timer timer = new Timer();
        timer.schedule(a, d, 4000);
        timer.schedule(b, d, 4000);

    }
}
